package com.freecloud.plug.mybatis.dao;

import com.freecloud.plug.mybatis.entity.User;
import com.freecloud.plug.mybatis.entity.UserAndDepartment;

import java.util.List;

/**
 * @Author: maomao
 * @Date: 2021-04-08 11:41
 */
public interface UserMapper {


    /**
     * 根据主键查询
     * @param id
     * @return
     */
    public User byId(Long id);

    /**
     * 新增
     * @param user
     * @return
     */
    public void save(User user);

    /**
     * 修改
     * @param user
     */
    public void update(User user);

    /**
     * 多表关联查询
     * @param id
     * @return
     */
    public UserAndDepartment getUserAndDepartmentById(Long id);

    /**
     * 关联查询，有N + 1问题
     * @param id
     * @return
     */
    public UserAndDepartment getUserAndDepartmentById1(Long id);


    /**
     * 关联查询，1对多
     * @param id
     * @return
     */
    public UserAndDepartment getUserAndDepartmentById2(Long id);


    /**
     * sql注入测试
     * @param id
     * @return
     */
    public List<User> byIdSqlInjection(String id);
}
